<template>
  <div style="width: 100%">

    <el-table v-loading="loading" :data="infoList">
      <el-table-column type="index" width="55" align="center" label="序号" />
      <el-table-column label="上次处置日期" align="center" prop="handleDate" />
      <el-table-column label="设备编号" align="center" prop="deviceNumber" />
      <el-table-column label="提醒对象" align="center" prop="noticeObject" />
      <el-table-column label="提醒类型" align="center" prop="noticeType" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleInfo(scope.row)"
            >前往处置</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>

  <!--<pagination
    v-show="total>0"
    :total="total"
    :page.sync="queryParams.pageNum"
    :limit.sync="queryParams.pageSize"
    @pagination="getList"
  />
--></template>

<script>
import {
  addAirMachine,
  getAirMachine,
  updateAirMachine,
} from "@/api/zhangping/zpMedicalDisinfectMachine";
import {
  addLightDisinfect,
  getLightDisinfect,
  updateLightDisinfect,
} from "@/api/zhangping/zpMedicalLightDisinfect";
import {
  addLightMonitor,
  getLightMonitor,
  updateLightMonitor,
} from "@/api/zhangping/zpMedicalLightMonitor";
import {
  addScrub,
  getScrub,
  updateScrub,
} from "@/api/zhangping/zpMedicalLightScrub";
import { medicalOrgDisinfectDeviceService } from "@/api/zhangping/zpMedicalTodo";
export default {
  name: "xdqxglTable",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 一企一档表格数据
      infoList: [],
      // 查询参数
      queryParams: {},
      // 表单参数
      detailForm: {},
      isEdit: false,
      lightScrubEditVisible: false,
      lightMonitorEditVisible: false,
      lightDisinfectEditVisible: false,
      disinfectMachineEditVisible: false,
    };
  },
  /*props: {
    editVisible: {
      type: Boolean,
      default: () => {
        return false
      }
    }
  },
  watch:{

  },
  computed: {
    show: {
      get () {
        return this.editVisible
      },
      set (val) {
        this.$emit('update:editVisible', val)
      }
    },
  },*/
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      medicalOrgDisinfectDeviceService().then((resp) => {
        this.infoList = resp.data;
        this.loading = false;
      });
    },
    handleInfo(row) {
      const id = row.id || this.ids;
      switch (row.noticeBusiness) {
        case "ZpLightScrub":
          {
            //紫外线灯擦拭
            getScrub(id).then((response) => {
              this.detailForm = response.data;
              this.isEdit = true;
              this.lightScrubEditVisible = true;
            });
          }
          break;
        case "ZpLightMonitor":
          {
            //紫外线灯强度监测
            getLightMonitor(id).then((response) => {
              this.detailForm = response.data;
              this.isEdit = true;
              this.lightMonitorEditVisible = true;
            });
          }
          break;
        case "ZpLightDisinfect":
          {
            //紫外线灯消毒
            getLightDisinfect(id).then((response) => {
              this.detailForm = response.data;
              this.isEdit = true;
              this.lightDisinfectEditVisible = true;
            });
          }
          break;
        case "ZpDisinfectMachine":
          {
            //空气消毒机监测
            getAirMachine(id).then((response) => {
              this.detailForm = response.data;
              this.isEdit = true;
              this.disinfectMachineEditVisible = true;
            });
          }
          break;
        default:
          break;
      }
    },
    /** 提交按钮 */
    submitLightScrubForm(form, id) {
      if (id != null) {
        updateScrub(form).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.lightScrubEditVisible = false;
          this.getList();
        });
      } else {
        addScrub(form).then((response) => {
          this.$modal.msgSuccess("新增成功");
          this.lightScrubEditVisible = false;
          this.getList();
        });
      }
    },
    submitLightDisinfectForm(form, id) {
      if (id != null) {
        updateLightDisinfect(form).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.lightDisinfectEditVisible = false;
          this.getList();
        });
      } else {
        addLightDisinfect(form).then((response) => {
          this.$modal.msgSuccess("新增成功");
          this.lightDisinfectEditVisible = false;
          this.getList();
        });
      }
    },
    submitLightMonitorForm(form, id) {
      if (id != null) {
        updateLightMonitor(form).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.lightMonitorEditVisible = false;
          this.getList();
        });
      } else {
        addLightMonitor(form).then((response) => {
          this.$modal.msgSuccess("新增成功");
          this.lightMonitorEditVisible = false;
          this.getList();
        });
      }
    },
    submitDisinfectMachineForm(form, id) {
      if (id != null) {
        updateAirMachine(form).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.disinfectMachineEditVisible = false;
          this.getList();
        });
      } else {
        addAirMachine(form).then((response) => {
          this.$modal.msgSuccess("新增成功");
          this.disinfectMachineEditVisible = false;
          this.getList();
        });
      }
    },
  },
};
</script>

<style></style>
